FROM node:20-alpine as base
# ENV PNPM_HOME="/pnpm"
# ENV PATH="$PNPM_HOME:$PATH"
# RUN corepack enable
RUN npm config set registry https://registry.npmmirror.com/

WORKDIR /app
COPY . .


RUN npm install


ENV NEXT_TELEMETRY_DISABLED 1

ENV NODE_ENV production

RUN  npm run build:stg

FROM node:20-alpine

WORKDIR /app

COPY --from=base /app/.next/standalone /app/standalone
COPY --from=base /app/.next/static /app/standalone/.next/static

EXPOSE 3004


ENV PORT 3004

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

ENV NEXT_SHARP_PATH=/app/standalone/node_modules/sharp
# RUN cd packages/apps/nextapp && npm run start
CMD [ "node" , "./standalone/server.js" ] 
